<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Example</title>
    <script src="base64.js"></script>
</head>
<body>
<h1>Base64.js</h1>
<textarea id="input" cols="80" rows="10"></textarea>
<br>
<button onclick="normal_encode()">普通Base64编码</button>
<button onclick="normal_decode()">普通Base64解码</button>
<button onclick="url_safe_encode()">URL_safe Base64编码</button>
<button onclick="url_safe_decode()">URL_safe Base64解码</button>
<br>
<textarea id="output" cols="80" rows="10" readonly></textarea>

<script type="text/javascript">
    function normal_encode() {
        var raw = document.getElementById("input").value;
        var encoded = BASE64.encode(raw);
        document.getElementById("output").value = encoded;
    }

    function normal_decode() {
        var raw = document.getElementById("input").value;
        var decoded = BASE64.decode(raw);
        document.getElementById("output").value = decoded;
    }

    function url_safe_encode() {
        var raw = document.getElementById("input").value;
        var encoded = BASE64.urlsafe_encode(raw);
        document.getElementById("output").value = encoded;
    }

    function url_safe_decode() {
        var raw = document.getElementById("input").value;
        var decoded = BASE64.urlsafe_decode(raw);
        document.getElementById("output").value = decoded;
    }
</script>
</body>
</html>
